package cn.xo68.democachehazelcast.config;

import cn.xo68.boot.cache.common.CacheConfiguration;
import cn.xo68.boot.cache.common.CacheConfigurer;
import cn.xo68.boot.cache.common.CacheConstant;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class WxCacheConfigurer implements CacheConfigurer {

    @Override
    public void addConfig(List<CacheConfiguration> configurations) {
        CacheConfiguration cacheConfiguration= CacheConfiguration.create("user")
                .timeoutSeconds(60*30)
                .build();
        configurations.add(cacheConfiguration);

        CacheConfiguration userCacheConfiguration= CacheConfiguration.create("userCache")
                .timeoutSeconds(60*30)
                .build();
        configurations.add(userCacheConfiguration);
    }

    @Override
    public CacheConfiguration getCacheDefault() {
        //默认保存30分钟
        CacheConfiguration cacheConfiguration= CacheConfiguration.create(CacheConstant.CACHE_NAME_DEFAULT)
                .timeoutSeconds(60*30)
                .build();
        return cacheConfiguration;
    }
}
